//1、引入发送请求的函数对象
import request from '@/utils/request';

//2、引入响应返回值的数据类型
import type {
  TrademarkPageListModel,
  TrademarkModel,
  TrademarkListModel,
} from './model/trademarkModel';

//3、定义请求地址的枚举
enum Api {
  GetTrademarkListApi = '/admin/product/baseTrademark',
  SaveTrademarkApi = '/admin/product/baseTrademark/save',
  DeleteTrademarkApi = '/admin/product/baseTrademark/remove',
  UpdateTrademarkApi = '/admin/product/baseTrademark/update',
}

/**
 * 获取品牌管理数据
 * @param page 当前页码
 * @param limit 每页条数
 * @returns TrademarkPageListModel
 */

export const reqGetTrademarkListData = (page: number, limit: number) => {
  return request.get<any, TrademarkPageListModel>(
    Api.GetTrademarkListApi + `/${page}/${limit}`
  );
};

/**
 * 添加品牌
 * @param tmName 品牌名称
 * @param logoUrl 品牌logo
 * @returns null
 */

export const reqSaveTrademark = (trademark: TrademarkModel) => {
  return request.post<any, null>(Api.SaveTrademarkApi, trademark
  );
};

/**
 * 更新品牌
 * @param tm 品牌对象
 * @returns null
 */

export const reqUpdateTrademark = (tm: TrademarkModel) => {
  return request.put<any, null>(Api.UpdateTrademarkApi, tm);
};

/**
 * 删除品牌
 * @param id 品牌对象
 * @returns null
 */

export const reqDeleteTrademark = (id: number) => {
  return request.delete<any, null>(Api.DeleteTrademarkApi + `/${id}`);
};
